import {
	baseUrl,
	token
} from "../utils/request.js"
export function updateUser(data) {
  return uni.request({
    url:  baseUrl +'/prod-api/system/user/profile/avatar',
	header: {
		'Authorization': 'Bearer ' + token()
	},
    method: 'POST',
    data: data
  });
  
}
export function upImage(data) {
	return uni.request({
		url: baseUrl + '/prod-api/common/upload64',
		header: {
			'Authorization': 'Bearer ' + token()
		},
		method: "POST",
		data: data
	});
}
export function getUserInfo() {
	return uni.request({
		url: baseUrl + '/prod-api/system/user/profile',
		header: {
			'Authorization': 'Bearer ' + token()
		},
		method: "GET"
	});
}
export function getAnimalInfo(param) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/animalInfo/list',
		method: "GET",
		data: param
	});
}
export function getAnimalDtil(param) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/animalInfo/' + param,
		method: "GET"
	});
}
export function getPlantInfo(param) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/plantInfo/list',
		method: "GET",
		data: param
	});
}
export function getPlantDtil(param) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/plantInfo/' + param,
		method: "GET"
	});
}
export function getMicrobeInfo(param) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/microbeInfo/list',
		method: "GET",
		data: param
	});
}
export function getMicrobeIDtil(param) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/microbeInfo/' + param,
		method: "GET"
	});
}
export function getpreventionInfo(param) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/preventionInfo/list',
		method: "GET",
		data: param
	});
}
export function getpreventionDtil(param) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/preventionInfo/' + param,
		method: "GET"
	});
}


export function getSpecyInfoList(param) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/specyInfo/list',
		method: "GET",
		data: param
	});
}


export function getSpecyInfo(id) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/specyInfo/' + id,
		method: "GET"
	});
}
export function getInfoByName(param) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/specyInfo/list',
		method: "GET",
		data: param
	});
}

export function getpreventionInfoByName(name) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/preventionInfo/list?pageNum=1&pageSize=10&specyName=' + name,
		method: "GET"
	})
}

export function selectDictLabel(datas, value) {
	var actions = [];
	Object.keys(datas).some((key) => {
		if (datas[key].value == ('' + value)) {
			actions.push(datas[key].label);
			return true;
		}
	})
	return actions.join('');
}


export function getClassify(specyType) {
	return uni.request({
		url: baseUrl + '/prod-api/portal/specyInfo/classify?specyType=' + specyType,
		method: 'GET'
	})
}
